/**
 * 
 */
package bean;

import javax.ejb.Remote;
import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContext;

/**
 * PatternBox: "SessionBean" implementation.
 * <ul>
 * <li>The SessionFacade is implemented as a session bean. The SessionFacade
 * manages the relationships between numerous BusinessComponents and provides a
 * higher level abstraction to the Client</li>
 * </ul>
 * 
 * @author Dirk Ehms, <a href="http://www.patternbox.com">www.patternbox.com</a>
 * @author Blito
 */
@Stateful
@Remote(ShoppingCart.class)
public class ShoppingCartBean implements ShoppingCart, java.io.Serializable {
	@PersistenceContext
	private EntityManager manager;
	/** This will be your object. */
	private Order component = new Order();

	/**
	 * This construtor creates a SessionBean instance.
	 */
	public ShoppingCartBean() {
	}

	public void buy(String product, int quantity, double price) {
		component.addPurchase(product, quantity, price);
	}

	public Order getOrder() {
		return component;
	}

	@Remove
	public void checkout() {
		manager.persist(component);
	}

}
